﻿using ExpenseSystem.Common;
using ExpenseSystem.Common.BaseModel;
using ExpenseSystem.Core.Authority;

namespace ExpenseSystem
{
    public static class SiteSetter
    {
        public static bool Set<T>(T data) where T:NormalModel,new ()
        {
            UserProfile userProfile = Authority.GetUserProfile();
            if (data!=null&&userProfile!=null)
            {
                if (data.Site > 0 && userProfile.SiteId != data.Site)
                    return false;
                data.Site = userProfile.SiteId;
                return true;
            }
            return false;
        }
    }
}